package co.rcantor.dev.siasar.asistencia;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TabHost;
import co.rcantor.dev.siasar.R;
import co.rcantor.dev.siasar.SIASARActivity;


public class FormPAsistencia extends TabActivity {
    
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.form);

	    Resources res = getResources();
	    TabHost tabHost = getTabHost();
	    TabHost.TabSpec spec;
	    Intent intent;
	    
	    intent = new Intent().setClass(this, TabAsistencia1.class);
	    spec = tabHost.newTabSpec("datos1").setIndicator("A", res.getDrawable(R.drawable.ic_tab_com1)).setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, TabAsistencia2.class);
	    spec = tabHost.newTabSpec("datos2").setIndicator("B", res.getDrawable(R.drawable.ic_tab_com1)).setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, TabAsistencia3.class);
	    spec = tabHost.newTabSpec("datos3").setIndicator("C", res.getDrawable(R.drawable.ic_tab_com1)).setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, TabAsistencia4.class);
	    spec = tabHost.newTabSpec("datos4").setIndicator("D", res.getDrawable(R.drawable.ic_tab_com1)).setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, TabAsistencia5.class);
	    spec = tabHost.newTabSpec("datos5").setIndicator("E", res.getDrawable(R.drawable.ic_tab_com1)).setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, TabAsistencia6.class);
	    spec = tabHost.newTabSpec("datos6").setIndicator("F", res.getDrawable(R.drawable.ic_tab_com1)).setContent(intent);
	    tabHost.addTab(spec);

	}
	
	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
   	
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.mnuOpc1:
        	AlertDialog.Builder builder = new AlertDialog.Builder(FormPAsistencia.this);
 	    	builder.setMessage("")
 	    	       .setPositiveButton("CONTINUAR", new DialogInterface.OnClickListener() {
 	    	           public void onClick(DialogInterface dialog, int id) {
 	    	        	finish();
 	    	   		    Intent intent = new Intent(FormPAsistencia.this,SIASARActivity.class);
 	    	   		    startActivity(intent);
 	    	           }
 	    	       });
 	    	AlertDialog alert = builder.create();
 	    	alert.show();
            return true;
        case R.id.mnuOpc2:
        	AlertDialog.Builder builder2 = new AlertDialog.Builder(FormPAsistencia.this);
 	    	builder2.setMessage("Desea volver al menu inicial sin guardar los cambios?")
 	    	       .setPositiveButton("SALIR", new DialogInterface.OnClickListener() {
 	    	           public void onClick(DialogInterface dialog, int id) {
 	    	        	finish();
 	    	        	Intent intent = new Intent(FormPAsistencia.this, SIASARActivity.class);
 	    	        	startActivity(intent);
 	    	        }
 	    	       });
 	    	AlertDialog alert2 = builder2.create();
 	    	alert2.show();
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }
	
}
